package com.android.hedgehog;

public class DataMatrixData {
	public int difficulty;
	public int[][] matrix;
	public int total = 0;
	public int playerGuess;
	public float speed = 2.2f;
	public String message = "";
	public int points = 0;
	int maxNumber = 7;
	int rowSize = 10;

	public DataMatrixData(int level) {
		difficulty = level;
		enumerate();
	}

	private void enumerate() {
		switch (difficulty) {
			case 2 :
				rowSize = 13;
				speed=2.3f;
				break;
			case 3 :
				maxNumber = 6;
				speed = 2.6f;
				break;
			case 4 :
				rowSize = 9;
				maxNumber = 5;
				speed = 2.6f;
				break;
			case 5 :
				rowSize=11;
				maxNumber = 6;
				speed = 2.8f;
				break;
			case 6 :
				rowSize = 12;
				maxNumber = 5;
				speed = 2.8f;
				break;
			case 7 :
				rowSize = 12;
				maxNumber = 5;
				speed = 3.1f;
				break;
			case 8 :
				maxNumber = 4;
				speed = 3.3f;
				break;
			case 9 :
				maxNumber = 5;
				rowSize = 16;
				speed = 3.1f;
				break;
			case 10 :
				maxNumber = 4;
				rowSize = 11;
				speed = 3.5f;
				break;
		}

		matrix = new int[rowSize][8];
		for (int i = 0; i < matrix.length; i++) {
			for (int j = 0; j < matrix[i].length; j++) {
				matrix[i][j] = (int) Math.round(Math.random() * maxNumber);
				if (matrix[i][j] == 1)
					total++;
			}
		}
	}

	public void checkAnswer(int[] input) {
		playerGuess = (input[0] * 100) + (input[1] * 10) + input[2];
		switch (Math.abs(total - playerGuess)) {
			case 0 :
				points = 12 + difficulty;
				message = "correct!  +" + points + " points ";
				break;
			case 1 :
				points = 8 + difficulty;
				message = "close enough.  +" + points + " points ";
				break;
			default :
				points = (5 + (Math.abs(total - playerGuess))) * -1;
				message = "wrong.  you lost  " + (points * -1) + " points ";
				break;
		}
	}

}
